import Vue from 'vue'
import {cloneDeep} from 'lodash'

export const GET_LIST = 'GET_LIST'
export const OSS_CONFIG = 'OSS_CONFIG'
export const SEARCH_INDEX = 'SEARCH_INDEX'
export const SET_ABNORMAL = 'SET_ABNORMAL'
export const SELECTLIST = 'SELECTLIST'

const state = {
  abnormal: false
}
const mutations = {
  [SET_ABNORMAL] (state) {
    state.abnormal = true
  },
  [SELECTLIST] (state, data) {
    state.parentList = data
  }
}
const actions = {
  [GET_LIST] ({commit, dispatch}, data) {
    let _data = cloneDeep(data)
    return new Promise((resolve, reject) => {
      Vue.req.post('http://10.10.14.90:8082/mareas/list', _data, {
        headers: {
          'Content-Type': 'application/json'
        }
      }).then(res => {
        resolve(res)
      }).catch(err => {
        reject(err)
      })
    })
  }
}

export default {
  state,
  mutations,
  actions
}
